home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Visual Database / Visual BASIC 5.0 (Ent. Edition) / Vb5ent Extractor.EXE / VB / SAMPLES / PGUIDE / MSFLEXGD / FFLEX.FRM (.txt) next >
Encoding:
Visual Basic Form  |  1996-12-04  |  6.2 KB  |  190 lines

  1. VERSION 5.00
  2. Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "MSFlxGrd.Ocx"
  3. Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.1#0"; "ComDlg32.OCX"
  4. Begin VB.Form Form1 
  5.    BorderStyle     =   1  'Fixed Single
  6.    Caption         =   "FlexGrid Sample"
  7.    ClientHeight    =   3930
  8.    ClientLeft      =   3030
  9.    ClientTop       =   5790
  10.    ClientWidth     =   8235
  11.    LinkTopic       =   "Form1"
  12.    MaxButton       =   0   'False
  13.    MinButton       =   0   'False
  14.    ScaleHeight     =   3930
  15.    ScaleWidth      =   8235
  16.    Begin VB.Data Data1 
  17.       Caption         =   "Data1"
  18.       Connect         =   "Access"
  19.       DatabaseName    =   ""
  20.       DefaultCursorType=   0  'DefaultCursor
  21.       DefaultType     =   2  'UseODBC
  22.       Exclusive       =   0   'False
  23.       Height          =   375
  24.       Left            =   6360
  25.       Options         =   0
  26.       ReadOnly        =   0   'False
  27.       RecordsetType   =   2  'Snapshot
  28.       RecordSource    =   "Title Author"
  29.       Top             =   3240
  30.       Visible         =   0   'False
  31.       Width           =   1815
  32.    End
  33.    Begin MSFlexGridLib.MSFlexGrid flex 
  34.       Bindings        =   "fFlex.frx":0000
  35.       DragIcon        =   "fFlex.frx":0010
  36.       Height          =   3135
  37.       Left            =   120
  38.       TabIndex        =   0
  39.       Top             =   600
  40.       Width           =   6135
  41.       _ExtentX        =   10821
  42.       _ExtentY        =   5530
  43.       Cols            =   3
  44.       FixedCols       =   0
  45.       BackColorFixed  =   0
  46.       ForeColorFixed  =   16776960
  47.       GridColor       =   -2147483630
  48.       HighLight       =   2
  49.       SelectionMode   =   1
  50.       AllowUserResizing=   1
  51.       BorderStyle     =   0
  52.    End
  53.    Begin MSComDlg.CommonDialog CommonDialog1 
  54.       Left            =   6480
  55.       Top             =   2640
  56.       _ExtentX        =   847
  57.       _ExtentY        =   847
  58.       FontSize        =   1.73857e-39
  59.    End
  60.    Begin VB.Image Image1 
  61.       Height          =   1440
  62.       Left            =   3720
  63.       Picture         =   "fFlex.frx":0452
  64.       Stretch         =   -1  'True
  65.       Top             =   600
  66.       Width           =   4215
  67.    End
  68.    Begin VB.Label Label1 
  69.       Alignment       =   2  'Center
  70.       BackColor       =   &H00FFFFFF&
  71.       BorderStyle     =   1  'Fixed Single
  72.       Caption         =   "Drag and Drop any column to pivot the data"
  73.       ForeColor       =   &H00808080&
  74.       Height          =   735
  75.       Left            =   6600
  76.       TabIndex        =   2
  77.       Top             =   0
  78.       Width           =   1335
  79.    End
  80.    Begin VB.Label lblTitle 
  81.       Alignment       =   2  'Center
  82.       BackColor       =   &H00000000&
  83.       Caption         =   "Flex Summary"
  84.       BeginProperty Font 
  85.          Name            =   "Arial"
  86.          Size            =   21.75
  87.          Charset         =   0
  88.          Weight          =   700
  89.          Underline       =   0   'False
  90.          Italic          =   0   'False
  91.          Strikethrough   =   0   'False
  92.       EndProperty
  93.       ForeColor       =   &H000000FF&
  94.       Height          =   615
  95.       Left            =   120
  96.       TabIndex        =   1
  97.       Top             =   0
  98.       Width           =   6135
  99.    End
  100. Attribute VB_Name = "Form1"
  101. Attribute VB_GlobalNameSpace = False
  102. Attribute VB_Creatable = False
  103. Attribute VB_PredeclaredId = True
  104. Attribute VB_Exposed = False
  105. Option Explicit
  106. Private Sub flex_DragDrop(Source As VB.Control, X As Single, Y As Single)
  107.     If flex.Tag = "" Then Exit Sub
  108.     flex.Redraw = False
  109.     flex.ColPosition(Val(flex.Tag)) = flex.MouseCol
  110.     DoSort
  111.     flex.Redraw = True
  112. End Sub
  113. Private Sub flex_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
  114.     flex.Tag = ""
  115.     If flex.MouseRow <> 0 Then Exit Sub
  116.     flex.Tag = Str(flex.MouseCol)
  117.     flex.Drag 1
  118. End Sub
  119. Private Sub Form_Load()
  120. On Error GoTo FormLoad_Err
  121.         
  122.   Data1.DatabaseName = CurDir & "\biblio.mdb"
  123.   Data1.Refresh
  124.   flex.Redraw = False
  125.   DoInitialSettings
  126.   DoSql
  127.   DoSort
  128.   flex.Redraw = True
  129. FormLoad_Exit:
  130. Exit Sub
  131. FormLoad_Err:
  132.     'advanced error handling is required if the database cannot be
  133.     'found as error 3024 would indicate.
  134.     If Err = 3024 Then
  135.         'set CommonDialog properties before showing
  136.         With CommonDialog1
  137.           .DialogTitle = "Unable to find the biblio.mdb file location"
  138.           .Filter = "(*.mdb)|*.mdb"
  139.           .InitDir = CurDir
  140.           .filename = "biblio.mdb"
  141.           .Flags = cdlOFNExplorer Or cdlOFNFileMustExist Or cdlOFNPathMustExist
  142.           .ShowOpen
  143.           'make sure the filename is not an empty string
  144.           If .filename <> "" Then
  145.             'make sure that the database file returned is indeed biblio.mdb
  146.             If Right(UCase(.filename), Len("biblio.mdb")) = "BIBLIO.MDB" Then
  147.             Data1.DatabaseName = .filename
  148.             End If
  149.             Resume
  150.           Else
  151.             Unload Me
  152.           End If
  153.         End With
  154.     ElseIf Err <> 0 Then ' another error
  155.         MsgBox "Unexpected Error: " & Err.Description
  156.         End
  157.     End If
  158.     Resume FormLoad_Exit
  159. End Sub
  160. Sub DoInitialSettings()
  161.     Dim i%
  162.     flex.Row = 0
  163.     flex.ColAlignment(0) = 7
  164.     For i = 0 To flex.Cols - 1
  165.         flex.Col = i
  166.         flex.CellFontSize = 14
  167.         flex.CellAlignment = 4
  168.         
  169.         flex.MergeCol(i) = True     ' Allow merge on Columns 0 thru 3
  170.         flex.ColWidth(i) = 2000     ' Set column's width
  171.     Next i
  172.     flex.MergeCells = flexMergeRestrictColumns
  173. End Sub
  174. Sub DoSql()
  175.     Dim mysql$
  176.     mysql$ = "SELECT "
  177.     mysql = mysql & "Publishers.[Company Name], "
  178.     mysql = mysql & "Authors.Author, "
  179.     mysql = mysql & "Titles.Title "
  180.     mysql = mysql & "FROM Authors INNER JOIN "
  181.     mysql = mysql & "(Publishers INNER JOIN ([title author] INNER JOIN Titles ON [title author].ISBN = Titles.ISBN) ON Publishers.PubID = Titles.PubID) "
  182.     mysql = mysql & "ON Authors.Au_ID = [title author].Au_ID "
  183.     Data1.RecordSource = mysql
  184. End Sub
  185. Sub DoSort()
  186.     flex.Col = 0
  187.     flex.ColSel = flex.Cols - 1
  188.     flex.Sort = 1 ' Generic Ascending
  189. End Sub
  190.